package com.lineage.data.item_etcitem;

import com.lineage.data.executor.ItemExecutor;
import com.lineage.server.model.Instance.L1ItemInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_ItemName;
import com.lineage.server.serverpackets.S_ServerMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import java.util.Iterator;

public class Lamp_Oil extends ItemExecutor {
  public static ItemExecutor get() {
    return new Lamp_Oil();
  }
  
  public void execute(int[] data, L1PcInstance pc, L1ItemInstance item) {
    Iterator<L1ItemInstance> iterator = pc.getInventory().getItems().iterator();
    while (iterator.hasNext()) {
      L1ItemInstance lightItem = iterator.next();
      if (lightItem.getItem().getItemId() == 40002) {
        lightItem.setRemainingTime(item.getItem().getLightFuel());
        pc.sendPackets((ServerBasePacket)new S_ItemName(lightItem));
        pc.sendPackets((ServerBasePacket)new S_ServerMessage(230));
        break;
      } 
    } 
    pc.getInventory().removeItem(item, 1L);
  }
}
